import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

//双色球中奖
public class Test2 {
    public static void main(String[] args) {
        //生成中奖号码
        int[] arr = creatNumber();
        System.out.println(Arrays.toString(arr));
        
        //用户想买的号码
        int[] userArr = userNumber();
        System.out.println(Arrays.toString(userArr));

        //判断是否中奖
        int redCount = 0;
        int blueCount = 0;
        for (int i = 0; i < userArr.length; i++) {
            for (int j = 0; j < arr.length; j++) {
                if(userArr[i] == arr[i]){
                    redCount++;
                    break;
                }
            }
        }
        if(userArr[userArr.length-1] == arr[arr.length-1]){
            blueCount++;
        }
        if(redCount == 6 && blueCount == 1){
            System.out.println("1000w");
        }else if(redCount == 6 && blueCount == 0){
            System.out.println("500w");
        }else if (redCount == 5 && blueCount == 1) {
            System.out.println("3000");
        }else if ((redCount == 5 && blueCount == 0) || (redCount == 4 && blueCount == 1)) {
            System.out.println("200");
        }else if ((redCount == 4 && blueCount == 0) || (redCount == 3 && blueCount == 1)) {
            System.out.println("10");
        }else if ((redCount == 2 && blueCount == 1) || (redCount == 1 && blueCount == 1) || (redCount == 0 && blueCount == 1)) {
            System.out.println("5");
        }else {
            System.out.println("没中奖");
        }
    }
    
    //生成中奖号码返回
    public static int[] creatNumber(){
        int[] arr = new int[7];
        Random random = new Random();
        //red
        for (int i = 0; i < 6; ) {
            int redNumber = random.nextInt(33) + 1;
            boolean flag = flagNumber(arr,redNumber);
            if(!flag){
                arr[i] = redNumber;
                i++;
            }
        }
        //blue
        arr[arr.length-1] = random.nextInt(16) + 1;
        return arr;
    }
    
    //用户买的号码
    public static int[] userNumber(){
        int[] arr = new int[7];
        Scanner scanner = new Scanner(System.in);
        //red
        for (int i = 0; i < 6; ) {
            System.out.println("请输入" + (i + 1) + "个红球号码");
            int redNumber = scanner.nextInt();
            if(redNumber >= 1 && redNumber <= 33){
                boolean flag = flagNumber(arr,redNumber);
                if(!flag){
                    arr[i] = redNumber;
                    i++;
                }
            }else {
                System.out.println("请重新输入");
            }
        }
        //blue
        while (true){
            System.out.println("请输入蓝球号码");
            int blueNumber = scanner.nextInt();
            if(blueNumber >= 1 && blueNumber <= 16){
                arr[arr.length-1] = blueNumber;
                break;
            }else {
                System.out.println("请重新输入");
            }
        }
        return arr;
    }

    //判断是否存在重复红球
    public static boolean flagNumber(int[] arr,int number){
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] == number){
                return true;
            }
        }
        return false;
    }
}
